#include <QtCore>

#include "move.h"

Move::Move( int old_x, int old_y,
            int new_x, int new_y ) : oldX( old_x ), oldY(old_y), newX(new_x), newY(new_y)
{
  extraMove = 0;
  deleteFigure = 0;
}

Move::Move( int old_x, int old_y,
            int new_x, int new_y,
            int deleteFigureX, int deleteFigureY ) : oldX( old_x ), oldY(old_y), newX(new_x), newY(new_y)
{
  extraMove = 0;
  deleteFigure = new QPoint( deleteFigureX, deleteFigureY );
}

Move::Move( int old_x, int old_y, 
            int new_x, int new_y,
            int extraMoveOldX, int extraMoveOldY,
            int extraMoveNewX, int extraMoveNewY ) : oldX( old_x ), oldY(old_y), newX(new_x), newY(new_y)
{
  qDebug() << "Creating move with extra Move:" << extraMoveOldX << ", " << extraMoveOldY << ", " << extraMoveNewX << ", " << extraMoveNewY << " THIS:" << this;
  extraMove = new Move(extraMoveOldX, extraMoveOldY, extraMoveNewX, extraMoveNewY);
  deleteFigure = 0;
}

bool Move::operator==( Move& move )
{
  bool result = false;
  if (    move.getOldX() == oldX && move.getOldY() == oldY
       && move.getNewX() == newX && move.getNewY() == newY
     ) result = true;

  return result;
}

Move::~Move()
{
  qDebug() << "~~ Move destructor called:" << oldX << ", " << oldY << ", " << newX << ", " << newY;
  if ( extraMove )    delete extraMove;
  if ( deleteFigure ) delete deleteFigure;
}

